const db = require("../db/index");
const moment = require('moment')

exports.loginloglists = (req, res) => {
    var sql =
        "select * from loginlog";
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data);
    });
};

// 搜索
exports.loginlogserch = (req, res) => {
    console.log(req.query)
    const { account , time }  = req.query
    var sql =
        `select * from loginlog where account like '%${account}%' and time like '%${moment(time).format('YYYY-MM-DD')}%'`;
    db.query(sql, [], (err, data) => {
        if(err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data)
    })
}